import { DIC } from '@/const/dic'

// 维保单表格列表
export const option = {
  index:true,
  indexLabel:'序号',
  border: true,
  selection: false,
  menuBtn: true,
  addBtn:false,
  cellBtn: false,
  editBtn: false,
  delBtn: false,
  dicData: DIC,
  columnBtn: false,
  refreshBtn:false,
  size: 'mini',
  align: "center",
  menuWidth: 300,
  menuAlign: "center",
  column: [
    {
      label: "审批单号",
      prop: "approvalNumber",
    },
    {
      label: "审批状态",
      prop: "approvalStatus",
      dicData: DIC.STATE_STATUS,
      slot: true
    },
    {
      label: "维保类型",
      prop: "maintenanceType",
      dicData: DIC.TROULBE_STATUS_WB_INT,
    },
    {
      label: "设备类别",
      prop: "categoryType"
    },
    {
      label: "设备编码",
      prop: "coded",
      slot: true
    },
    {
      label: "设备名称",
      prop: "name",
        width: 100,
      slot: true
    },
    {
      label: "型号",
      prop: "marking",
      slot: true
    },
    {
      label: "品牌",
      prop: "brand",
      slot: true
    },
    {
      label: "申请部门/申请人",
      prop: "departmentAndName",
        width: 150,
      slot: true,
    },
    {
      label: "申请时间",
      prop: "applicationTime",
    width: 140,
    }
  ]
}
//
export const optionAdd = {
    index:true,
    size: 'mini',
    indexLabel:'序号',
    border: true,
    selection: true,
    menuBtn: true,
    addBtn:false,
    cellBtn: false,
    editBtn: false,
    delBtn: false,
    dicData: DIC,
    align: "center",
    menuWidth: 110,
    menuAlign: "center",
    columnBtn: false,
    refreshBtn:false,
    column: [{
        label: "设备类别",
        prop: "equipmentTypeId",
        slot: true,
    },{
        label: "设备编号",
        prop: "coded",
    },{
        label: "设备名称",
        prop: "name",
    },{
        label: "设备型号",
        prop: "marking",
    },{
        label: "品牌",
        prop: "brand",
    },{
        label: "仓库",
        prop: "warehouseId",
        slot: true,
    },{
        label: "预约时间",
        prop: "time",
        slot: true,
    }]
}
//
export const optionSelect = {
    index: true,
    size: 'mini',
    indexLabel:'序号',
    border: true,
    selection: true,
    addBtn: false,
    cellBtn: false,
    editBtn: false,
    delBtn: false,
    searchBtn: true,
    dicData: DIC,
    align: "center",
    menu: false,
    menuWidth: 80,
    menuAlign: "center",
    columnBtn: false,
    refreshBtn: false,
    column: [{
        label: "设备类别",
        prop: "equipmentTypeId",
        slot: true,
    },{
        label: "设备编码",
        prop: "coded",
    },{
        label: "设备名称",
        prop: "name",
    },{
        label: "设备型号",
        prop: "marking",
    },{
        label: "仓库",
        prop: "warehouseId",
        slot: true,
    },{
        label: "品牌",
        prop: "brand",
    }]
}
//
export const tableOptionModeSelectRLDateFormRules = {
    beginDate: [
        {type: 'date', required: true, message: '请输入开始时间', trigger: 'change'},
    ],
    endDate: [
        {type: 'date', required: true, message: '请选择开始时间', trigger: 'change'},
    ],
    beginTime: [
        {required: true, message: '请输入结束时间', trigger: 'change'},
    ],
    endTime: [
        {required: true, message: '请选择结束时间', trigger: 'change'},
    ],
}
//
export function jsonToArray(nodes) {
  var r=[];
  if (Array.isArray(nodes)) {
    for (var i=0, l=nodes.length; i<l; i++) {
      r.push(nodes[i]); // 取每项数据放入一个新数组
      if (Array.isArray(nodes[i]["children"])&&nodes[i]["children"].length>0)
       // 若存在children则递归调用，把数据拼接到新数组中，并且删除该children
        r = r.concat(jsonToArray(nodes[i]["children"]));
          delete nodes[i]["children"]
    }
  }
  return r;
}
  